import React from "react";
import FileApi, {FileObj} from "@/api/web/FileApi.ts";
import {ViewProcessor} from "@/components/FilePreviewProcess/processors/_index.ts";

const _main = ({fileObj}: { fileObj: FileObj }) => {
    return (
        <audio
            src={FileApi.getFileLink(fileObj.path)}
            controls
        />
    )
}

export default class AudioView extends ViewProcessor {
    ViewFunctionComponent = () => <_main fileObj={this.fileObj}/>

    getName = () => "音频"

    isViewAble = () => {
        return !!this.fileObj.contentType && this.fileObj.contentType.startsWith("audio")
    }

    protected uniKey = "AudioView"
}
